/**
 * 
 */
package com.roc.service;

import java.util.List;
import java.util.Map;

import com.roc.bean.JsonBean;
import com.roc.bean.MerinfoChangeBean;
import com.roc.bean.MerinfoDetail;
import com.roc.bean.TermBean;
import com.roc.dao.DaoException;
import com.roc.pojo.AuditingItem;
import com.roc.pojo.Esmidinfo;
import com.roc.pojo.EsmidinfoMerinfo;
import com.roc.pojo.EsmidinfoTmp;
import com.roc.pojo.MerchantModuleRight;
import com.roc.pojo.MerinfoChange;
import com.roc.pojo.MerinfoStatusChange;
import com.roc.pojo.Module;
import com.roc.pojo.Operators;
import com.roc.pojo.TReceive;
import com.roc.pojo.TblDictionaryLayerItem;
import com.roc.pojo.TblEditMchtExtendInfo;
import com.roc.pojo.TblEditMchtInf;
import com.roc.pojo.TblMchtBizFee;
import com.roc.pojo.TblMchtInf;
import com.roc.pojo.susesMerinfo;
import com.roc.web.action.merinfo.MerinfoAlloatSearchCondtion;


/**
 * @author RenPengFei 2013-5-18 下午3:38:24
 */
public interface IMerchantServices {

	/**
	 * 登陆
	 * 
	 * @param loginMerchant
	 * @return
	 * @throws ServiceException
	 */
	Operators login(Operators loginMerchant) throws ServiceException;
	void loginAfter(Operators loginMerchant) throws ServiceException;

	
	Operators findMerchantByNo(String accountNo) throws ServiceException;

	Operators modifyPwd(Operators merchant) throws ServiceException;
	
	String addMerchant(Operators merchant,Operators operators)throws ServiceException;

	Operators loadMerchat(Long merchantId) throws ServiceException;
	List<Operators> findSubMerchant(Long merchantId,String merType)throws ServiceException;
	List<Operators> findRecomenderMerchant(Long recomenderId)throws ServiceException;
     List<Operators> findSomeMerchant(String merType,Long merchantId,String orgCode)throws ServiceException;
    List<Operators> findRecommenders()throws ServiceException;
	void cancelMerchant(Operators merchant,String operators)throws ServiceException;
	void recoverMerchant(Operators merchant,String operators)throws ServiceException;
	Operators modifyMerchant(Operators merchant,String operators) throws ServiceException;
	
	void delete(Operators merchant,String operators)throws ServiceException;
	
	Map<String, Operators> listAllMerchants(String merType,long merchantId,String orgCode) throws ServiceException;
	long isDeleted(long merchantId)throws ServiceException;
	//查询代理商下的所有代理商
	List<Operators> listAllSubMerchants(long merchantId)throws ServiceException;
	//查询某个代理商的一级代理商 type 为 03
	List<Operators> queryLowOneAgent(String supId) throws ServiceException;
	//查询代理商集合
	List<Operators> listOperatorsAgent(String orgCode) throws ServiceException;
	public Map<String, Operators> listAll()throws ServiceException; 
	
	//通过操作员ID查询该操作员所拥有的所有权限
	List<MerchantModuleRight> queryMerchantPowerByNo(String accountNo) throws ServiceException ;
	//根据mcc查询行业类别
	String  queryMccTypeByCode(String code)throws ServiceException;
	//根据银行编码查询省份，城市，银行
	String[] queryBackBranch(String  backBranchId)throws ServiceException;
	
	//按照操作员的级别查询对应的权限
	List<Module> queryModuleType(String merType) throws ServiceException;
	
	//修改操作员权限
	void editUpdateMerchantPower(String accountNo,String[] str,Operators merchant) throws ServiceException;
	List<Object> listOperators()throws ServiceException;
	
	//查询一级代理
	 List<Object> queryFirstLevelMerchants()throws ServiceException;
	 //查询结算周期
	 List<Object> queryCycle()throws ServiceException;
	
	 //变更商户信息
	 void updateMerchant(EsmidinfoTmp  merinfoTmp,Operators  op,List<TermBean> termBeanList)throws ServiceException;
	 //商户号序列号
	  String queryMerByNo(String  mer)throws ServiceException;
	 
	 //根据商户号查询商户详细信息
	  MerinfoDetail  queryMerByMid(String  mid)throws ServiceException;
	  //商户初审
	  void checkMerinfoOne(String merchantNo,Operators op,AuditingItem au,String[] value)throws ServiceException;
	  //商户业务复审
	  void checkMerinfoFour(EsmidinfoTmp tmp,Operators op,AuditingItem au,String[] value)throws ServiceException;
	  //商户复审
	  void checkMerinfoTwo(String merchantNo,Operators op,AuditingItem au,EsmidinfoMerinfo mer,String[] value,List<TermBean> terList)throws ServiceException;
	  //商户终审
	  void checkMerinfoThree(EsmidinfoTmp tmp,Operators op,AuditingItem au,EsmidinfoMerinfo mer,List<TermBean> terList)throws Exception;
	  //修改商户状态
	  void updadteMerinfoFlag(String mid,String  flag)throws ServiceException;
	  
	 //查询复审，终审审核意见
	  List<Object> queryAuditingList(String mer )throws ServiceException;
	  //查询商户信息(简单信息)
	  Esmidinfo queryEsmidinfoTmp(String mid) throws ServiceException;
	  //查询商户信息和详细信息（临时表）
	  EsmidinfoTmp queryMerinfoTmp(String mid)throws ServiceException;
	  Esmidinfo queryMerinfobyid(String mid)throws ServiceException;
	  public List<Object> queryYjPosAgent(String  id)
		throws ServiceException;
	  
	  int initOpePwdErrTimes()
				throws ServiceException;
	  
	  
	  String insertMerinfoChange(MerinfoChange  merinfoChange,TblEditMchtInf merinfoEdit,TblMchtInf merinfo,Operators op)throws ServiceException;
		 public MerinfoChange queryMerinfoChangeById(Long id)throws ServiceException;
		 public void checkMerinfoChange(MerinfoChange merinfoChange,Operators op,AuditingItem au)throws ServiceException;
		  //查询商户关联信息
		 EsmidinfoMerinfo queryEsmidinfoMerinfo(String mid) throws ServiceException;
		 
     public List<Object> queryAuditingListChange(String mid,String auditingCode) throws ServiceException;
	 public void updateMerinfoChange(MerinfoChange merinfoChange)throws ServiceException;
	 public MerinfoChange queryUniqueById(Long id)throws ServiceException;
	 
	 public boolean checkStatus(String mid, String dealCode);
	/**
	 * 通过ID查询直接下级代理商
	 * @param merchantId
	 * @return
	 * @throws ServiceException
	 */
	 public	List<Operators> listLowOneMerchants(long merchantId)throws ServiceException;
	 
	 /**
	 * 通过ID删除操作员表
	 * @param agentId
	 * @param accountNo 删除人
	 * @return
	 * @throws ServiceException 
	 */
	public int deleteAgentMer(long agentId,String accountNo) throws ServiceException;
	
	
	/**
	 * 删除操作员表，权限，分润规则
	 * @param agentId
	 * @param accountNo
	 * @return
	 * @throws ServiceException 
	 */
	public int deleteMerInfo(long agentId,String accountNo,Operators op) throws ServiceException;
	
	public void checkMerinfoChangeOne(MerinfoChange merinfoChange,Operators op,AuditingItem au)throws ServiceException; 
	public List<TermBean> queryTermByMid(String mid) throws ServiceException;
	/**
	 * 通过商户号修改状态 正式表
	 * @param mid
	 * @param flag  启用1 停用 99
	 * @param accountNo 当前操作员
	 * @return
	 * @throws ServiceException
	 */
	public int updateMerchantFlag(String mid,int flag,String accountNo) throws ServiceException;
	public boolean queryMerinfoChangeByMid(String mid, String flag)throws ServiceException;
	
	/**
	 * 直接添加正式商户
	 * @param merinfoTmp
	 * @param op
	 * @param termBeanList
	 * @param flag
	 * @throws ServiceException
	 */
	 void insertMerinfoForReal(EsmidinfoTmp  merinfoTmp,Operators  op,List<TermBean> termBeanList,String[] value, String posBrandCode)throws ServiceException;

    
	 /**
	  * 保存可疑商户
	  * @param susesMerinfo
	  * @throws ServiceException
	  */
	  void saveKyMer(susesMerinfo susesMerinfo) throws ServiceException;
	  
	  /**
	   * 查询所有代理商
	   * @return
	   * @throws ServiceException
	   */
	  public List<Operators> listAllAgent() throws ServiceException;
	  
/**********************************************************************开发*************************************************/
	/**
	 * 进件保存商户信息
	 * @param merchantInfo  页面商户信息
	 * @param op 操作员信息
	 * @return String　返回失败信息或成功信息 
	 * @author zbl
	 * */
	String insertMerinfo(TblEditMchtInf  merchantInfo,Operators  op)throws ServiceException;
	
	/**
	 * 进件保存商户信息
	 * @param merchantInfo
	 * @param op
	 * @return
	 * @throws ServiceException
	 */
	String saveMerinfo(TblEditMchtInf  merchantInfo,Operators  op)throws ServiceException;
	
	/**
	 * 审核查询商户详细信息
	 * @param merinfoNo 临时商户号
	 * @param showName 根据code显示名称
	 * @param isRebut  是否加载驳回原因
	 * @param  isOpName 是否显示进件人员名称
	 * @return TblEditMchtInf  商户信息
	 * @author zbl   
	 * */
	TblEditMchtInf queryMerinfoTmpInfo(String merinfoNo,boolean showName,boolean isRebut,boolean isOpName)throws ServiceException;
	
	/**
	 * 审核查询直营商户详细信息
	 * @param merinfoNo 临时商户号
	 * @param showName 根据code显示名称
	 * @param isRebut  是否加载驳回原因
	 * @param  isOpName 是否显示进件人员名称
	 * @return TblEditMchtInf  商户信息
	 * */
	TblEditMchtInf queryPreMerinfoTmpInfo(String merinfoNo,boolean showName,boolean isOpName)throws ServiceException;
	
	 /**
	   * 查询商户信息
	   * @return
	   * @throws DaoException
	   */
	  public TblMchtInf queryMerchat(String merchtNo)throws ServiceException;
	
	/**
	 * 审核商户信息
	 * @param op 操作员
	 * @param merinfo　临时商户信息
	 * @param type  是否批量审核
	 * @return TblEditMchtInf  商户信息
	 * @author zbl   
	 * */
	  String checkMerinfo(Operators op,TblEditMchtInf merinfo)throws ServiceException;
	  void checkMerinfo(TblEditMchtInf merinfo,Operators op)throws ServiceException;//批量审核
	  List<?> queryNeedCheckMerinfo(int count)throws ServiceException;//查询需要审核的商户数据
	
	/**
	 * 驳回进件商户信息重新提交
	 * @param merchantInfo  页面商户信息
	 * @param op 操作员信息
	 * @return void 
	 * @author zbl
	 * */
	String editMerinfo(TblEditMchtInf merchantInfo,Operators op,String merRejectFlag)throws ServiceException;
	
	/**
	 * 修改图片信息
	 * @param merchantInfo  页面商户信息
	 * @param op 操作员信息
	 * @return  
	 * @author 
	 * */
	public String modifyPicInfo(TblMchtInf merinfo, Operators op) throws ServiceException;
	
	/**
	 * 查询商户详情，正式表；可参考queryMerinfoTmpInfo
	 * @param rkType 角色类型（查看详情）
	 * */
	public TblMchtInf queryMerinfoDetailInfo(String merinfoNo,boolean showName,String rkType)throws ServiceException;

	
	/**
	 * 查询终端风控信息,结算信息,手续费
	 * */
	public TblMchtInf queryOtherMerinfoInfo(String merinfoNo,boolean showName,TblMchtInf inf)throws ServiceException;
	
	/**
	 * 保存领件信息
	 * @param mchId
	 * @return
	 * @throws ServiceException
	 */
	public List<String> updateTReceiveInfo(Operators op,String merInfoIdList) throws ServiceException;
	
	/**
	 * 根据类别查询在系统已存在多少数量
	 * @param  type 类型
	 * @param merNo  商户号
	 * @param params 参数
	 * */
	JsonBean queryCount(String merNo,String type,String params,Operators op)throws ServiceException;
	
	/**
	 * 根据结算卡账户查询已进件数
	 * @param params 参数
	 * */
	JsonBean queryCountByAccountNo(String accountNo)throws ServiceException;
	
	/**
	 * 根据商户号查询最新结算卡号
	 * @param params 参数
	 * */
	String queryAccountByMer(String merNo)throws ServiceException;
	
	/**
	 * 根据商户号查询结算周期
	 * @param  mid 商户号
	 * @param  type  是否正式表
	 * @param  showName 是否显示名称
	 * */
	String[] queryMchtBizDealArray(String mid,boolean type,boolean showName) throws ServiceException;
	
	/**
	 * 根据商户名称查询已经存在的商户
	 * @param mid 商户号
	 * @param  name 商户名称
	 *  @param  realTable 是否正式表
	 * */
	JsonBean queryMchtCountByName(String mid,String name,boolean realTable) throws ServiceException;
	
	
	 /**
         * 根据商户号查询对应的商户下的终端数量
         * @param mid 商户号
         * */
        JsonBean getMchtNameRealCount(String mid) throws ServiceException;
	/**
	 * 根据手机号查询存在的条数
	 * @param  name 手机号
	 *  @param  realTable 是否正式表
	 * */
	JsonBean queryMchtCountByPhone(String name,boolean realTable) throws ServiceException;
	MerinfoChangeBean queryMerinfoChangeById(String id)throws ServiceException;
	

	JsonBean  changeMerinfoStatusCheck(String mid,String type,String account) throws ServiceException;
	JsonBean  changeMerinfoStatus2(String mid,String type,String account,MerinfoStatusChange merinfoStatusChange) throws ServiceException;
	
	       
        /**
         * 根据商户号更改商户状态（冻结）
         * @param mid  商户号
         * @param type 更新的状态
         * @param account 操作员账号
         * */
	JsonBean  changeMerinfoStatus(String mid,String type,String account) throws ServiceException;
	/**
	 * 保存商户变更信息领件
	 * @Title: queryTChangeReceiveInfo
	 * @Description:TODO(...)
	 * @param op
	 * @param editMerinfo
	 * @return
	 * @author jdd
	 * @throws ServiceException 
	 * @date: 2017年1月5日 下午4:21:11
	 *
	 */
	 public List<String> queryTChangeReceiveChange(Operators op, String merInfoIdList) throws ServiceException;
	JsonBean queryOperatorByAccountNo(String accountNO) throws ServiceException;
	
	String queryPhoneByAccountNo(String accountNO) throws ServiceException;
	
	JsonBean sendMsg( String accountNO,String verifyCode) throws ServiceException;
	

	public TblMchtInf queryMerinfoInfoById(String merinfoNo)throws ServiceException;
	
	 /**
		 * 商户释放
		 * @param op
		 * @param merInfoIdList
		 * @return
		 */
		public List<String> merinfoRelease(Operators op, String merInfoIdList)  throws ServiceException;
		/**
		 * 商户分配
		 * @param op
		 * @param merInfoIdList
		 * @return map {success: list, error:msg}
		 * @throws ServiceException
		 */
		public Map<String,Object> merinfoAlloat(MerinfoAlloatSearchCondtion alloatOp,Operators op, String merInfoIdList)  throws ServiceException;
		/**
		 * 商户分配代理商需查询所有子级代理
		 * @return
		 * @throws ServiceException
		 */
		public List<Operators> getSubAgent(Operators op)throws ServiceException;
		/**
		 * 商户分配给下级代理
		 * @param mchtId
		 * @param agentId
		 * @return
		 * @throws ServiceException
		 */
		public Map<String,Object> assginMerchtToAgent(String mchtId,String oldAgentId,String newAgentId,Operators op)throws ServiceException;
		/**
		 * 查找原代理商
		 * @param mchtId
		 * @return
		 * @throws ServiceException
		 */
		public Operators findOldAgent(String mchtId)throws ServiceException;
		
		/**
		 * 批量修改商户状态
		 * @param midList
		 * @param type 0-冻结，1-解冻，2-注销，3-开通
		 * @param account
		 * @return
		 * @throws ServiceException
		 */
		List<String> changeMerinfoStatusBanch(List<List<String>> midList,String type,String account) throws ServiceException;
		
		/**
		 * 商户审核通过-获取商户开通的产品类型信息(移除t1 t0)
		 * @param mid
		 * @return
		 * @throws ServiceException
		 */
		public List<String> queryMchtBizDealChecked(String mid) throws ServiceException;
		
		public Operators queryOperByRoleAndOrg(String roleType, String orgCode) throws ServiceException;
		
		public List<Operators> queryAllOneAgent(String companyid) throws ServiceException; 
		
		public TblDictionaryLayerItem loadInstalledArea(String areaCode, String flag);
		
		public String getInstalledCity(String ucBccdCode);
		
		public String getInstalledProvince(String ucBccdCode);
		
		/**
		 * 由商户号查询临时商户信息
		 * @param merId
		 * @return
		 * @throws ServiceException
		 */
		public TblEditMchtInf getTblEditMchtInfByMerId(String merId) throws ServiceException;
		
		/**
		 * 由商户号查询商户被领件次数
		 * @param merId
		 * @return
		 * @throws ServiceException
		 */
		public Long getTReceiveCountInfByMerId(String merId) throws ServiceException;
		
		/**
		 * 编辑暂存商户信息
		 * @param merinfoTmp
		 * @param op
		 * @param flag
		 * @return
		 * @throws ServiceException
		 */
		public String editMerTempSaveInfo(TblEditMchtInf merinfoTmp, Operators op, boolean flag) throws ServiceException;
		/**
		 *商户发展人下拉列表
		 * @param merId
		 * @return
		 * @throws ServiceException
		 */
		Map getOpIdsTreeBySuperId(Operators op) throws ServiceException;
		
		Operators getOpertorsByAccountNo(String  accountNo) throws ServiceException;
		
		
		/**
		 * 预审核直营商户信息
		 * @param op 操作员
		 * @param merinfo　临时商户信息
		 * @return TblEditMchtInf  商户信息
		 * @author jjj   
		 * */
		String preCheckMerinfo(Operators op,TblEditMchtInf merinfo)throws ServiceException;
		
		/**
		 * 查询直营商户驳回记录
		 * @param merNo
		 * @return
		 * @throws ServiceException
		 */
		public TblEditMchtExtendInfo getMerExtendInfo(String merNo) throws ServiceException;
		
		/**
		 * 校验法人/非法人证件名称和号码是否对应
		 * @param cardName
		 * @param cardNo
		 * @return
		 * @throws ServiceException
		 */
		public boolean validateIdInfo(String cardName, String cardNo, String verifyFlag) throws ServiceException;
		
		/**
		 * 云商宝商户进件
		 * @param receiveId
		 * @throws ServiceException
		 */
		public void busiServePoInsertMerinfo(Long receiveId) throws ServiceException;
		
		/**
		 * 查询云商宝商户费率
		 * @param mchtNo
		 * @return
		 */
		public List<TblMchtBizFee> queryYsbMchtBizFeeList(String mchtNo) throws ServiceException;
		
		/**
		 * 编辑云商宝商户费率信息
		 * @param mchtBizFees
		 * @return
		 * @throws ServiceException
		 */
		public String editYsbMchtFeeInfo(List<TblMchtBizFee> mchtBizFees, Operators op, TblMchtInf mchtInf) throws ServiceException;
}

